package com.zhangxiaofanfan.web.consumer;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

/**
 * kafka 消费者
 *
 * @author zhangxiaofanfan
 * @date 2024-07-02 18:56:59
 */
@Slf4j
@Component
public class KafkaConsumer {
    @Value("${spring.kafka.topic}")
    private String topic;

    @KafkaListener(topics = {"${spring.kafka.topic}"}, groupId = "spring-boot-group")
    public void onXXXMessage(String message) {
        // 打印数据
        log.info("[onXXXMessage]\t[message:{}]", message);
    }
}
